#!/bin/sh

SERVER=/u01/xxl-sso-server
cd $SERVER

case "$1" in
  start)
    CRONOLOG_PATH=/usr/local/sbin/cronolog
    if [ ! -f "$CRONOLOG_PATH" ]; then
        CRONOLOG_PATH=/usr/sbin/cronolog
        if [ ! -f "$CRONOLOG_PATH" ]; then
            CRONOLOG_PATH=/usr/bin/cronolog
        fi;
    fi;
    nohup java -XX:-UseGCOverheadLimit -Xmx1024m -jar $SERVER/xxl-sso-server-1.1.1-SNAPSHOT.jar 2>&1 | $CRONOLOG_PATH ./logs/nohup_%Y%m%d.log &
    echo $[$!-1] > $SERVER/server.pid
    ;;

  stop)
    kill `cat $SERVER/server.pid`
    rm -rf $SERVER/server.pid
    ;;

  restart)
    $0 stop
    sleep 1
    $0 start
    ;;

  *)
    echo "Usage: run.sh {start|stop|restart}"
    ;;

esac

exit 0

